import 'package:flutter/material.dart';

/// 边框配置扩展
extension BorderConfigExtension on Widget {
  /// 配置渐变边框
  /// [borderColor] - 边框颜色（两侧的颜色）
  /// [borderWidth] - 边框宽度
  /// [borderRadius] - 边框圆角
  Widget configBorderWidget({
    Color borderColor = const Color(0xFFFF8A3C),
    double borderWidth = 1.0,
    double borderRadius = 8.0,
  }) {
    return Container(
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(borderRadius),
        gradient: LinearGradient(
          colors: [
            borderColor.withOpacity(0.7), // 左侧不透明
            borderColor.withOpacity(0.2), // 中间透明
            borderColor.withOpacity(0.7), // 右侧不透明
          ],
          stops: const [0.0, 0.5, 1.0],
          begin: Alignment.centerLeft,
          end: Alignment.centerRight,
        ),
      ),
      padding: EdgeInsets.all(borderWidth),
      child: Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(borderRadius - borderWidth),
          color: Colors.transparent,
        ),
        child: this,
      ),
    );
  }
}
